package org.jeecg.modules.demo.hd.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.jeecg.modules.demo.hd.entity.AppMyProjectClickdetail;
import org.jeecg.modules.demo.hd.entity.AppUserGoldDetail;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.demo.hd.vo.UserDayGoldTotalVo;
import org.jeecg.modules.demo.hd.vo.UserDayGoldTypeTotalVo;
import org.jeecg.modules.demo.hd.vo.total.ChildUserGoldInputVo;
import org.jeecg.modules.demo.hd.vo.total.ChildUserGoldViewVo;
import org.jeecg.modules.demo.hd.vo.total.UserGoldDetailViewVo;
import org.jeecg.modules.demo.hd.vo.userGoldDetailModelVo;

import java.util.List;

/**
 * @Description: app_user_gold_detail2
 * @Author: jeecg-boot
 * @Date: 2025-02-04
 * @Version: V1.0
 */
public interface IAppUserGoldDetailService extends IService<AppUserGoldDetail> {


    String addDetail(userGoldDetailModelVo vo);

    String addNewDetail();

    /**
     * 向用户发放金币奖励
     *
     * @param model
     * @return
     */
    Integer addGoldDetail(AppMyProjectClickdetail model);

    /**
     * 向用户发放金币奖励
     *
     * @param model
     * @param code  临时创建code
     * @return
     */
    Integer addGoldDetail(AppMyProjectClickdetail model, String code);

    /**
     * 扣除用户金币
     *
     * @param userId
     * @param goldNum
     * @return
     */
    String exchangeCash(String userId, double goldNum);

    /**
     * 最后一条点击记录
     *
     * @param userId
     * @return
     */
    AppMyProjectClickdetail getLastDetail(String userId);


    /**
     * 团队奖励
     *
     * @param userId
     * @param goldNum
     * @param goldType 4 团队奖励金币，仅限兑换工币   5 团队奖励金币，可兑换现金
     * @return
     */
    String commissionGold(String userId, double goldNum, String goldType);

    /**
     * 兑换工币扣除 金币
     *
     * @param userId
     * @param goldNum
     * @return
     */
    String exchangeShare(String userId, double goldNum);


    void clean();

    /**
     * 获取每日用户获得金币统计
     *
     * @param day
     * @return
     */
    List<UserDayGoldTotalVo> getUserDayGoldTotalList(String day);

    /**
     * 获取当前用户当天获得的所有广告收益
     *
     * @return
     */
    Double getCurrentUserDayGold();

    /**
     * 获取当前用户指定日期获得的所有广告收益
     *
     * @param day
     * @param userId
     * @return
     */
    Double quereUserGoldTotalByDay(String day, String userId);

    /**
     * 获取当前用户指定日期获得的所有广告收益(包含团队激励、点击广告奖励)
     *
     * @param day
     * @param userId
     * @return
     */
    Double quereUserGoldTotalByDayForSettlement(String day, String userId);

    /**
     * @return
     */
    List<UserDayGoldTypeTotalVo> getUserDayGoldTypeTotalList();

    IPage<ChildUserGoldViewVo> getChildUserGoldNumTotalList(String genCode, String day, IPage page);

    ChildUserGoldViewVo getChildUserGoldNumTotal(String genCode, String day);

    /**
     * 获取用户金币获得明细（给团队长看）
     *
     * @param vo
     * @param page
     * @return
     */
    IPage<UserGoldDetailViewVo> getUserGoldDetailList(ChildUserGoldInputVo vo, IPage page);


    List<UserGoldDetailViewVo> getAllUserGoldDetailList(ChildUserGoldInputVo vo);


    IPage<ChildUserGoldViewVo> getUserGoldTotalList(ChildUserGoldInputVo vo, IPage page);


    /**
     * 更新金币明细状态
     *
     * @param userId
     * @param day
     * @return
     */
    Boolean updateGoldState(String userId, String day);

    IPage<UserGoldDetailViewVo> getUserGoldList(String deviceId, String userId, String day, IPage page);

    /**
     * 查看用户当前设备 补偿次数
     *
     * @param userId   用户id
     * @param deviceId 设备ID
     * @param day      日期
     * @return
     */
    Integer quereUserGoldSubsidiesCount(String userId, String deviceId, String day);
}
